$(function(){
	frame.secSelect($("input[name='secId']"));
	$('#dlg').dialog("close");
	$("#dg").edatagrid({
		url:frame.fullUrl('/smdc/market/page.json')
	});
});

function click_search() {
	var param = $("#search_param").form("getData");
	$('#dg').datagrid('load',param);
}


function click_open_update() {
	$("#update_dialog").dialog("open");
}

function click_update() {
	var data = $("#update_param").form("getData");
	$.ajax(frame.fullUrl('/smdc/market/update.json'), {data:data, mask:true, type:"post"});
}

function click_update_all() {
	var data = $("#update_param").form("getData");
	$.ajax(frame.fullUrl('/smdc/market/update.json'), {
		data : {
			beginDate : data.beginDate
		},
		mask : true,
		type : "post"
	});
}

function click_row_edit(){
	var row = $('#dg').datagrid("getSelected");
	$('#ff').form("clear");
	$('#ff').form("load",row);
	$('#dlg').dialog("open");
}

function click_row_add(){
	$('#ff').form("clear");
	$('#dlg').dialog("open");
}

function dlg_click_save(){
	$('#ff').form('ajaxSubmit',{ 
		url: frame.fullUrl('/smdc/market/save.json'),
		success: function(data){
			if(data.sucesse==true){
				dlg_click_cancle();
				click_search();
			}
		} 
	});
}

function dlg_click_delete() {
	$.messager.confirm('确认', '您确认想要删除吗？', function(r) {
		if (!r) {
			return;
		}
		$('#ff').form('ajaxSubmit',{
			url: frame.fullUrl('/smdc/market/delete.json'),
			mask : true,
			success : function(data) {
				if (data.sucesse) {
					$('#dlg').dialog("close");
					click_search();
				}
			}
		});
	});
}

function dlg_click_cancle(){
	$('#dlg').dialog("close");
}
